import { defineStore } from 'pinia'
import { Names, UserType } from './store-util'
import eventBus from '@/Util/EventBus'
export const useUserStore = defineStore(Names.User, {
    state: () => {
        return {
            user: <UserType>{}
        }
    },
    getters: { // 类似于computed，支持缓存

    },

    actions: { //支持同步和异步修改
        setUser(user: any) {
            this.user = user
            eventBus.emit('updateName', user.username)
        }
    }
})